package luj.game.robot.internal.net.http.collect;

import luj.game.robot.api.network.http.RobotHttpMeta;
import luj.game.robot.api.network.http.RobotHttpModule;

final class UriResolver {

  UriResolver(MHandlerImpl handler) {
    _handler = handler;
  }

  String resolve() {
    RobotHttpModule cursor = _handler.getModule();
    var parent = new StringBuilder(64);

    while (cursor != null) {
      parent.insert(0, cursor.path());
      cursor = cursor.parent();
    }

    RobotHttpMeta meta = _handler._meta;
    return parent.append(meta.path()).toString();
  }

  private final MHandlerImpl _handler;
}
